<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- connectivity.qdoc -->
  <title>Networking and Connectivity | Qt 5.14</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="index.html">Qt 5.14</a></td><td >Networking and Connectivity</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.14.2 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#network-communication">Network Communication</a></li>
<li class="level1"><a href="#websockets">WebSockets</a></li>
<li class="level1"><a href="#world-wide-web-support">World Wide Web Support</a></li>
<li class="level1"><a href="#inter-process-communication">Inter-Process Communication</a></li>
<li class="level1"><a href="#serial-port-communication">Serial Port Communication</a></li>
<li class="level1"><a href="#bluetooth-communication">Bluetooth Communication</a></li>
<li class="level1"><a href="#near-field-communication">Near Field Communication</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Networking and Connectivity</h1>
<span class="subtitle"></span>
<!-- $$$topics-network-connectivity.html-description -->
<div class="descr"> <a name="details"></a>
<p>Qt provides classes for both high-level and low-level network communication, classes for web integration, and classes for interprocess communication.</p>
<p>For high-level network traffic, <a href="../qtnetwork/qtnetwork-index.html">Qt Network</a> provides an abstraction layer over the operations used, showing only high-level classes and functions. Qt Network can also handle lower level protocols like TCP and UDP. Classes like <a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a> and <a href="../qtnetwork/qudpsocket.html">QUdpSocket</a> enable the developer to send and receive messages using the TCP or UDP protocol.Name resolution is done with <a href="../qtnetwork/qhostinfo.html">QHostInfo</a>. <a href="../qtnetwork/qhostinfo.html">QHostInfo</a> is called before creating a network connection with <a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a> or <a href="../qtnetwork/qudpsocket.html">QUdpSocket</a>. Filtering and redistributing network traffic via proxies can handled by the QNetWorkProxy class.</p>
<p>Qt Network also provides the <a href="../qtnetwork/bearer-management.html">Bearer Management</a> API. It has functions that can start or stop network interfaces and roam between access points. It does however not take care of the network configurations itself. The platform needs to take care of that.</p>
<p><a href="../qtwebengine/qtwebengine-index.html">Qt WebEngine</a> offers a Chromium-based web engine that enables using web content in your application. <a href="../qtwebengine/qtwebengine-index.html">Qt WebEngine</a> can render HTML5, XHTML, and SVG documents, and execute Javascript.</p>
<p>Qt also offers functionalities for <i>inter-process communication</i> (IPC). The class <a href="../qtcore/qprocess.html">QProcess</a> is used to start external programs. <a href="../qtdbus/qtdbus-index.html">Qt D-Bus</a> provides support for D-Bus, an interprocess communication and remoteprocedure calling mechanism. It mostly communicates via a central server application, called a bus. However, it is also possible to let applications communicate directly with each other. <a href="../qtcore/qsharedmemory.html">QSharedMemory</a> provides access to a shared memory segment by multiple threads and processes. It is however also possible for a single process to exclusively lock that shared memory.</p>
<a name="network-communication"></a>
<h2 id="network-communication">Network Communication</h2>
<p>Qt supports a wide range of network communication, with a focus on HTTP, TCP, and UDP.</p>
<p>At the HTTP level, the <a href="../qtnetwork/qtnetwork-index.html">Qt Network</a> module offers the network access API, which consists mainly of <a href="../qtnetwork/qnetworkrequest.html">QNetworkRequest</a>, <a href="../qtnetwork/qnetworkaccessmanager.html">QNetworkAccessManager</a>, and <a href="../qtnetwork/qnetworkreply.html">QNetworkReply</a>. Put simply, the <a href="../qtnetwork/qnetworkrequest.html">QNetworkRequest</a> resembles an HTTP request, which gets passed to the <a href="../qtnetwork/qnetworkaccessmanager.html">QNetworkAccessManager</a> to send the request on the wire; this class returns a <a href="../qtnetwork/qnetworkreply.html">QNetworkReply</a>, which enables parsing the HTTP reply. The network access API uses the socket classes mentioned below (for TCP and SSL) internally.</p>
<p>For communication at the socket level, <a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a>, <a href="../qtnetwork/qudpsocket.html">QUdpSocket</a> and <a href="../qtnetwork/qsslsocket.html">QSslSocket</a> should be used. These classes offer a synchronous API through the waitFor* methods as well as an asynchronous API; if possible (i.e&#x2e; if the event loop is running), the asynchronous API should always be preferred. Qt also offers <a href="../qtnetwork/qtcpserver.html">QTcpServer</a> to enable the server-side part of a TCP communication. Please note that there is no HTTP server class in Qt.</p>
<p>For secure communication via SSL, Qt Network offers a wide range of classes alongside the central <a href="../qtnetwork/qsslsocket.html">QSslSocket</a>, e.g&#x2e; <a href="../qtnetwork/qsslcertificate.html">QSslCertificate</a>, <a href="../qtnetwork/qsslconfiguration.html">QSslConfiguration</a> and <a href="../qtnetwork/qsslerror.html">QSslError</a>. The only supported backend for SSL in Qt is OpenSSL, which needs to be installed separately.</p>
<p>For mobile devices, Qt Network offers the <a href="../qtnetwork/bearer-management.html">bearer management</a> API to track the status of a connection (e.g&#x2e; getting notified about online/offline status or whether Wifi or 3G is used).</p>
<p>Qt also offers HTTP support in QML by either using HTTP explicitly via <a href="../qtqml/qtqml-javascript-qmlglobalobject.html#xmlhttprequest">XmlHttpRequest</a>, or by transparently using HTTP URLs in e.g&#x2e; Image sources.</p>
<p>Related Topics:</p>
<ul>
<li><a href="../qtnetwork/qtnetwork-index.html">Qt Network</a> - module documentation<ul>
<li><a href="../qtnetwork/network.html">Network Programming API</a></li>
<li><a href="../qtnetwork/qtnetwork-programming.html">Network Programming with Qt</a></li>
<li><a href="../qtnetwork/qtnetwork-module.html">Qt Network C++ Classes</a></li>
<li><a href="../qtnetwork/ssl.html">Secure Sockets Layer (SSL) Classes</a></li>
<li><a href="../qtnetwork/bearer-management.html">Bearer Management</a></li>
</ul>
</li>
<li><a href="../qtqml/qtqml-documents-topic.html#resource-loading-and-network-transparency">Resource Loading and Network Transparency</a> - network and URL transparency in QML</li>
</ul>
<a name="websockets"></a>
<h2 id="websockets">WebSockets</h2>
<p>An alternative to direct TCP or HTTP communication is to use the <a href="nolink">WebSocket</a> protocol (<a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a>). It is a two-way communication protocol on top of the TCP protocol to utilize existing web infrastructure without having to create additional client-server based communication. The <a href="../qtwebsockets/qtwebsockets-index.html">Qt WebSockets</a> module provides both a QML and C++ API, in addition to several examples to demonstrate its use.</p>
<a name="world-wide-web-support"></a>
<h2 id="world-wide-web-support">World Wide Web Support</h2>
<p>Qt makes it easy to embed web content into your Qt application using features of the Qt <a href="nolink">WebEngine</a> layout engine. The Qt <a href="nolink">WebEngine</a> module equips Qt with support for a broad range of standard web technologies that make it possible to embed HTML content styled with CSS and scripted with JavaScript into your Qt application. <a href="../qtwebengine/qtwebengine-index.html">Qt WebEngine</a> facilitates both integration with traditional <a href="../qtwidgets/qwidget.html">QWidget</a> based desktop applications as well as embedding into Qt Quick QML applications.</p>
<p>For more information see <a href="topics-web-content.html">Integrating Web Content</a>.</p>
<a name="inter-process-communication"></a>
<h2 id="inter-process-communication">Inter-Process Communication</h2>
<p>Qt provides several ways to implement Inter-Process Communication (IPC) in Qt applications.</p>
<p>The cross-platform <a href="../qtnetwork/qtnetwork-index.html">Qt Network</a> module provides classes that make network programming portable and easy. It offers high-level classes (e.g&#x2e;, <a href="../qtnetwork/qnetworkaccessmanager.html">QNetworkAccessManager</a>, QFtp) that communicate using specific application-level protocols, and lower-level classes (e.g&#x2e;, <a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a>, <a href="../qtnetwork/qtcpserver.html">QTcpServer</a>, <a href="../qtnetwork/qsslsocket.html">QSslSocket</a>) for implementing protocols.</p>
<p>The cross-platform shared memory class, <a href="../qtcore/qsharedmemory.html">QSharedMemory</a>, provides access to the operating system's shared memory implementation. It allows safe access to shared memory segments by multiple threads and processes. Additionally, <a href="../qtcore/qsystemsemaphore.html">QSystemSemaphore</a> can be used to control access to resources shared by the system, as well as to communicate between processes.</p>
<p>The <a href="../qtdbus/qtdbus-index.html">Qt D-Bus</a> module is a cross-platform library you can use to implement IPC using the D-Bus protocol. It extends Qt's <a href="../qtcore/signalsandslots.html">signals and slots</a> mechanism to the IPC level, allowing a signal emitted by one process to be connected to a slot in another process.</p>
<p>The cross-platform class <a href="../qtcore/qprocess.html">QProcess</a> can be used to start external programs as child processes, and to communicate with them. It provides an API for monitoring and controlling the state of the child process. <a href="../qtcore/qprocess.html">QProcess</a> gives access to the input/output channels of child process by inheriting from <a href="../qtcore/qiodevice.html">QIODevice</a>.</p>
<p>The <a href="../qtnetwork/qlocalsocket.html">QLocalSocket</a> class provides a local socket. On Windows this is a named pipe and on Unix this is a local domain socket. The <a href="../qtnetwork/qlocalserver.html">QLocalServer</a> class provides a local socket based server. This class makes it possible to accept incoming local socket connections.</p>
<p>Related Topics:</p>
<ul>
<li><a href="../qtdbus/qtdbus-index.html">Qt D-Bus</a> - module documentation<ul>
<li><a href="../qtdbus/usingadaptors.html">Using Qt D-Bus Adaptors</a></li>
<li><a href="../qtdbus/qdbusdeclaringsignals.html">Declaring Signals in D-Bus Adaptors</a></li>
<li><a href="../qtdbus/qdbusdeclaringslots.html">Declaring Slots in D-Bus Adaptors</a></li>
<li><a href="../qtdbus/qdbustypesystem.html">The Qt D-Bus Type System</a></li>
<li><a href="../qtdbus/qdbusxml2cpp.html">Qt D-Bus XML compiler (qdbusxml2cpp)</a></li>
</ul>
</li>
<li><a href="../qtnetwork/qlocalsocket.html">QLocalSocket</a></li>
<li><a href="../qtcore/qsharedmemory.html">QSharedMemory</a></li>
</ul>
<a name="serial-port-communication"></a>
<h2 id="serial-port-communication">Serial Port Communication</h2>
<p>The <a href="../qtserialport/qtserialport-index.html">Qt Serial Port</a> module provides a C++ API for communicating through serial ports, using the RS-232 standard. It works with physical ports and also with drivers that emulate these ports. Examples of serial port emulators include virtual COM ports, com0com emulators, and the Bluetooth SPP.</p>
<p>This module is designed to make serial port programming easier and portable. As of Qt 5.2, it is supported on <a href="windows.html">Windows</a>, <a href="macos.html">macOS</a>, and <a href="linux.html">Linux</a>.</p>
<p>Related topics:</p>
<ul>
<li><a href="../qtserialport/qtserialport-index.html">Qt Serial Port</a> - module documentation</li>
<li><a href="../qtserialport/qtserialport-module.html">Qt Serial Port C++ Classes</a></li>
</ul>
<a name="bluetooth-communication"></a>
<h2 id="bluetooth-communication">Bluetooth Communication</h2>
<p>The <a href="../qtbluetooth/qtbluetooth-index.html">Qt Bluetooth</a> module provides both C++ and QML APIs for the short-range (less than 100 meters) wireless protocol developed by the <a href="http://www.bluetooth.org">Bluetooth Special Interest Group</a>. It provides classic Bluetooth and Bluetooth Low Energy features.</p>
<p>Related topics:</p>
<ul>
<li><a href="../qtbluetooth/qtbluetooth-index.html">Qt Bluetooth</a> - module documentation<ul>
<li><a href="../qtbluetooth/qtbluetooth-overview.html">Bluetooth Classic</a></li>
<li><a href="../qtbluetooth/qtbluetooth-le-overview.html">Bluetooth Low Energy</a></li>
<li><a href="../qtbluetooth/qtbluetooth-module.html">Qt Bluetooth C++ Classes</a></li>
<li><a href="../qtbluetooth/qtbluetooth-qmlmodule.html">Qt Bluetooth QML Types</a></li>
</ul>
</li>
</ul>
<a name="near-field-communication"></a>
<h2 id="near-field-communication">Near Field Communication</h2>
<p>The <a href="../qtnfc/qtnfc-index.html">Qt NFC</a> module provides both C++ and QML APIs for the extremely short-range (less than 20 centimeters) wireless protocol developed by the <a href="http://www.nfc-forum.org">NFC Forum</a>.</p>
<p>Related topics:</p>
<ul>
<li><a href="../qtnfc/qtnfc-index.html">Qt NFC</a> - module documentation<ul>
<li><a href="../qtnfc/qtnfc-overview.html">Qt NFC Overview</a></li>
<li><a href="../qtnfc/qtnfc-module.html">Qt NFC C++ Classes</a></li>
<li><a href="../qtnfc/qtnfc-qmlmodule.html">Qt NFC QML Types</a></li>
</ul>
</li>
</ul>
</div>
<!-- @@@topics-network-connectivity.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
